home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $FindInFolder < prev    next >
Encoding:
Text File  |  1994-10-11  |  2.0 KB  |  61 lines  |  [TEXT/KEEN]

  1. # $FindInFolder : hard-set the folderName, /string/ to find,
  2. # and max number of lines to check below - this will produce
  3. # a list of all text files which contain the string (full path names).
  4. # Takes no input, output to stdout. Output is ascii sorted by full path name.
  5. # Use eg to pick out all source files with a particular revision date near the top.
  6. # If you run in immediate mode (by holding down the <Shift> key when selecting hAWK)
  7. # there will be a progress display of the file names.
  8. # Note since "match" is used, your string can be a regular expression. With plain
  9. # text, the match counts anywhere on the line, not just at the beginning or at
  10. # word boundaries. Eg to match a full line exactly except for beginning and ending
  11. # white space use 
  12. #     if (match($0, /^[ \t]*Your plain text here\.[ \t]*$/)) ############### the /string/
  13. #    (remember to escape metacharacters such as ^the period above with a '\')
  14. # (On a Quadra, looks at about 300 - 500 files a minute)
  15.  
  16. # Old searches, in storage:
  17. # "Spot:Moses:" /Oct 6 94 - CodeWarrior happy/
  18. # "Spot:Apple Sample Code:AppsToGo:"
  19. # "Spot:Apple Sample Code:AppsToGo:"
  20.  
  21. BEGIN {
  22.     folderName = "Rodime:DTSDraw:"; ## "Disk:folder:...:folder:...:top folder to search:"
  23.     maxLines = 42;     ## set very large if your string is not near tops of files always
  24.     
  25.     ################## enter /string/ to find also, below in ExamineFile ############
  26.     
  27.     DoAFolder(folderName);
  28.     print ""
  29.     print ""
  30.     print "String was found in", numMatched, "files."
  31.     }
  32.  
  33. function DoAFolder(fldr, i, j, numNested, numFiles, fldrArray, fileArray)
  34.     {
  35.     numNested = nested(fldr, fldrArray);
  36.     numFiles = list(fldr, fileArray);
  37.     for (i = 1; i <= numFiles; ++i)
  38.         ExamineFile(fileArray[i]);
  39.     for (j = 1; j <= numNested; ++j)
  40.         DoAFolder(fldrArray[j]);
  41.     }
  42.  
  43. function ExamineFile(file,        lineCount)
  44.     {
  45.     progress(file);
  46.     lineCount = 1;
  47.     while (getline < file > 0)
  48.         {
  49.         if (match($0, /SetOrigin/)) ############### the /string/
  50.             {
  51.             ++numMatched;
  52.             print file;
  53.             break;
  54.             }
  55.         ##++lineCount;
  56.         ##if (lineCount > maxLines)
  57.         ##    break;
  58.         }
  59.     close(file);
  60.     }
  61.